	void drawAxis() 
	{
		SetFont(OpenFont(DEFAULTFONT, 15, 1), 0x000000);

		for (double i=0-((fmod(x11, px))/stepX); i<=800; i+=200)
		{
			if ((i>0)&&(i<100))
			{
				std::ostringstream right;
				right << x22;
				DrawTextRect(10, 580, 790, 600, right.str().c_str(),
						ALIGN_RIGHT);
			}
			else
			{
				if ((i>=100)&&(i<200))
					{
						std::ostringstream left;
						left << x11;
						DrawTextRect(20, 580, 790, 600, 
                                                left.str().c_str(), ALIGN_LEFT);
					}
			}

			std::ostringstream number;
			number << (float)((float)x11+(float)(i*stepX));
			if (i<=400)
			{
				DrawTextRect(int(floor(i+20)), 580, 800, 600,
					number.str().c_str(), ALIGN_LEFT);
			}
			else
			{
				DrawTextRect(0, 580, int(floor(i-10)), 600,
					number.str().c_str(), ALIGN_RIGHT);
			}

			DrawLine(int(floor(i)), 0, int(floor(i)), 600, 0xDDDDDD);
		}

		for (double i=0-((fmod(y11, py))/stepY); i<=600; i+=150)
		{
			if ((i>0)&&(i<75))
			{
				std::ostringstream up;
				up << y22;
				DrawTextRect(10, 10, 800, 600, up.str().c_str(),
						ALIGN_LEFT | VALIGN_TOP);
			}
			else
			{
				if ((i>=75)&&(i<150))
					{
						std::ostringstream down;
						down << y11;
						DrawTextRect(10, 560, 800, 600, down.str().c_str(),
								ALIGN_LEFT | VALIGN_TOP);
					}
			}

			std::ostringstream number;
			number << (float)((float)y11+(float)(i*stepY));
			if (i<30)
			{
				DrawTextRect(10, 600-int(floor(i+40)), 800, 600-int(floor(i+60)),
					number.str().c_str(), ALIGN_LEFT);
			}
			else
			{
				DrawTextRect(10, 600-int(floor(i-10)), 800, 600-int(floor(i+10)),
					number.str().c_str(), ALIGN_LEFT);
			}

			DrawLine(0, 600-int(floor(i)), 800, 600-int(floor(i)), 0xDDDDDD);
		}

		DrawLine((int)floor(-(x11/stepX)), 0,
			(int)floor(-(x11/stepX)), 600, 0x999999);
		DrawLine(0, 600-(int)floor(-(y11/stepY)), 800,
			600-(int)floor(-(y11/stepY)), 0x999999);
	}

	void draw()		 
	{
		double x = 0;		
		mu::Parser p;			
		p.DefineVar("x", &x);	
		p.SetExpr(expr);  
		int linex1 = 0, 		
			linex2 = 0, 	  
			liney1 = 0, 	 
			liney2 = 0;		 

		try
		{
			int color = funcs.size()%2==1 ? 0x000000 : 0x666666;

			for (x=x11; x<x22; x+=stepX)
			{
				linex1 = linex2;
				liney1 = liney2;	
            
				linex2 = (int)floor((x/stepX)-(x11/stepX));
				liney2 = 600-(int)floor((p.Eval()/stepY)-(y11/stepY));

				if (liney2<0) liney2=-1;		  
				if (liney2>600) liney2=601;		 
				DrawLine(linex1, liney1, linex2, liney2, color);
			}
		}
		catch (mu::Parser::exception_type &e)	 
		{
			funcs.pop_back();	  
			char *mess = new char[e.GetMsg().size()];
			copy(e.GetMsg().begin(), e.GetMsg().end(), mess);
		 	Message(ICON_ERROR, "Ошибка построения!",
		       	mess, 5000);				
		}
		if (update) FullUpdate ();
	}

	void clear(int flag)
	{
		if (flag==1)
		{
			funcs.clear();
			ClearScreen();
			drawAxis();
		}
		std::string temp;
		for (int j=0; expr[j]!=0; j++)
			temp += expr[j];
		funcs.push_back(temp);
		draw();
	}

	void plot()
	{
		if (first)			
		{				  
			first = false;
			clear(1);
		}
		else			
			Dialog(ICON_QUESTION, "Вопрос",
			"Вы хотите стереть предыдущий график?",
			"Да", "Нет", clear);
	}